<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/releaseOrderlist.css"/>
		<script src="js/jquery-2.1.0.js"></script>
		<script>
			$.ajax("/fengwei/PreOrder/getUser",{
				type:"get",
				data:{

				},
				success:function(data){
					console.log(data)
					var dataObj = eval('('+data+')');
					if(dataObj.length<1){
						alert("没有订单，或者订单没有被接受，去下单")
					}

					for(var i = 0;i<dataObj.length;i++){
						var orderList = document.getElementById('orderList');
						var newDiv = document.createElement('div');//创建一个新的div
						newDiv.setAttribute('id', 'order_goods');
						newDiv.setAttribute('class', dataObj[i].preorderId);
						orderList.appendChild(newDiv);
						newDiv.innerHTML = "<div class='order_goods_msg'>名称：<span class='goods_name'>"+dataObj[i].preorderName+"</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
								"产地：<span class='goods_place'>"+dataObj[i].preorderCity+"</span> <br />" +
								"所在地址：<span class='goods_school'>"+dataObj[i].preorderAdess+"</span><br />" +
								"截止时间：<span class='goods_time'>"+dataObj[i].preorderCuttime+"</span> <br />" +
								"总价格：<span class='goods_price'>￥"+dataObj[i].preoderTotalprice+"</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
								"数量：<span class='goods_num'>"+dataObj[i].preorderCount+dataObj[i].preoderUnit+"</span><br />"+
								"<span class='state_txt'>订单状态：</span>" +
								"<a href='releaseExpressStatus.html?preorderId="+dataObj[i].preorderId+"'><img  class='chakan_img' src='img/chakan.png'/></a>" +
								"<input id='button' type='button' disabled = 'disabled' _id='"+dataObj[i].preorderId+"' value='确认收货'>"+
								"</div>";
					}



						$("#button").click(function(){
							var preorderId = $(this).attr("_id")
							if(preorderId==4){
									$("#button").removeAttr("disabled");
//									将状态改为5，完成交易
									$.ajax("/fengwei/PreOrder/changeStatus",{
										type:"post",
										data:{
											'status':5,
											'preorderId':preorderId
										},
										success:function(){
											alert("本次交易完成")
										},
										error:function(){

										}

									})
								}
							})


				},
				error:function(){

				}

			})
		</script>

	</head>
	<body>	
		<div id="head">
			<a href=”#” onClick="javascript :history.back(-1);"> <img class="img_return" src="img/return.png"/> </a>
			<span class="head_txt">我的发单</span>
		</div>     <!--end -->
		
		<div id="orderList">
			<!--<div id="order_goods">-->
				<!--<div class="order_goods_msg">名称：<span class="goods_name">大闸蟹</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-->
								  	      <!--产地：<span class="goods_place">成都</span> <br />-->
								  	      <!--所在学校：<span class="goods_school">四川省 成都市 四川旅游学院</span><br />-->
								  	      <!--截止时间：<span class="goods_time">2017.3.3</span> <br />-->
								  	      <!--总价格：<span class="goods_price">￥50</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-->
	 								       <!--数量：<span class="goods_num">6kg</span><br />-->
	 			<!-- -->
	 			<!-- -->
		 			<!--<span class="state_txt">-->
		 				<!--订单状态：	-->
		 			<!--</span>-->
					<!--<a href="###"><img  class="chakan_img" src="img/chakan.png"/></a>-->

					<!--<input id='button' type='button' disabled = 'disabled' value='确认收货'>-->
				<!-- -->
				<!--</div>	-->
			<!--</div>   &lt;!&ndash;box end&ndash;&gt;-->
		</div>
		
	</body>
</html>
